#pragma once
#include"HashTable.h"


namespace cfl
{
	
	
	template<class K, class V>
	class map
	{
		struct MapofK
		{
			const K& operator()(const pair<K, V>& kv)
			{
				return kv.first;
			}
		};

		typedef HashTable<K, pair<const K, V>,MapofK> Hash;
	public:
		typedef typename Hash::iterator iterator;
		typedef typename Hash::const_iterator const_iterator;

		iterator begin()
		{
			return _hash.begin();
		}

		iterator end()
		{
			return _hash.end();
		}

		pair<iterator,bool> insert(const pair<K, V> kv)
		{
			pair<iterator,bool> it = _hash.insert(kv);
			return make_pair(iterator(it.first._node,&_hash), it.second);
		}

		V& operator[](const K& key)
		{
			pair<iterator, bool> it = _hash.insert(make_pair(key, V()));
			return it.first._node->_date.second;
		}

	private:
		Hash _hash;
	};

}
